package cn.cslg.service.impl;
import cn.cslg.dao.UserDao;
import cn.cslg.dao.impl.UserDaoImpl;
import cn.cslg.domain.User;
import cn.cslg.service.UserService;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    UserDao dao = new UserDaoImpl();
    @Override
    public boolean login(String username, String password) throws SQLException {
        boolean flag = dao.login(username,password);
        return flag;
    }

    @Override
    public boolean register(User user) {
        //如果用户存在返回false 不存在返回true插入成功
        //用户存在返回false
        boolean flag = dao.findone(user.getUsername());
        //如果用户不纯存在flag为true
        if(flag){
            dao.insert(user);
        }
        return flag;
    }
}
